<?php if(isset($model)): ?>

<?php
  $fields = field_get_items('lonex_category_item', $model, 'field_model_images');

  if(is_array($fields)) {
    $large_file = file_create_url($fields[0]['uri']);
    $large_image = l('<img title="'. $fields[0]['title'] .'" src = "' . $large_file . '">', $large_file, array(
      'html' => true,
      'attributes' => array(
        'rel' => 'lightbox[roadtrip]',
        'class' => array('thumbnail', 'large'),
        'id' => 0
      )
    ));

    foreach($fields as $index => $field) {
      $file = file_create_url($field['uri']);
      $images[] = l('<img title="'. check_plain($field['title']) .'" src = "' . $file . '">', $file, array(
        'html' => true,
        'attributes' => array(
          //'rel' => 'lightbox[roadtrip]',
          'class' => array('thumbnail', 'small'),
          'id' => $index,
        )
      ));
    }

    ?>

  <div class="span5">
    <?php print $large_image; ?>
  </div>

  <div class="span4 row">
    <ul class="thumbnails">
      <?php foreach($images as $image): ?>
      <li class="span2">
        <?php print $image; ?>
      </li>
      <?php endforeach; ?>
    </ul>
  </div>

  <?php
  }
  ?>
<!--  --><?php //drupal_add_js('
//  ', 'inline');?>
<?php endif; ?>
